package com.cljz.peipei.present.activity;

import com.cljz.peipei.base.BaseP;
import com.cljz.peipei.model.net.api.Api;
import com.cljz.peipei.model.net.bean.PeopleNumBean;
import com.cljz.peipei.ui.activity.BeginActivity;
import com.cljz.peipei.utils.L;

import cn.droidlover.xdroidmvp.net.ApiSubcriber;
import cn.droidlover.xdroidmvp.net.NetError;
import cn.droidlover.xdroidmvp.net.XApi;

/**
 * Created by apple on 2017/4/17.
 */

public class BeginP extends BaseP<BeginActivity>{
    public void getNumber() {
        Api.getResponseInfoAPI().getPeopleNumData()
                .compose(XApi.<PeopleNumBean>getApiTransformer())
                .compose(XApi.<PeopleNumBean>getScheduler())
                .compose(getV().<PeopleNumBean>bindToLifecycle())
                .subscribe(new ApiSubcriber<PeopleNumBean>() {
                    @Override
                    protected void onFail(NetError error) {

                    }
                    @Override
                    public void onNext(PeopleNumBean peopleNumBean) {
                        L.e(peopleNumBean.getData());
                        if ("0".equals(peopleNumBean.getCode())) {
                            getV().showPeopleNum(peopleNumBean);
                        }
                    }
                });
    }
}
